/**
 * File SendMessageOneShotBehaviour.java created by Pablo Díaz Fernández
 * on 28/10/2011 for the project supply-chain-simulator
 */
package org.lsk.pfc.scsim.model.behaviour;

import jade.core.AID;
import jade.core.behaviours.OneShotBehaviour;
import jade.lang.acl.ACLMessage;

/**
 * @author Pablo Díaz Fernández
 * 
 */
public final class SendMessageOneShotBehaviour extends OneShotBehaviour {

	/**
	 * Serial version ID.
	 */
	private static final long serialVersionUID = 91189372582260749L;

	/**
	 * Destination of the message.
	 */
	private AID destination;

	/**
	 * Message to send.
	 */
	private String message;

	/**
	 * Aim of the message.
	 */
	private int aim;

	/**
	 * Constructor that initializes the attributes of the object.
	 *
	 * @param destination Name of the agent receptor or the message.
	 * @param message Text of the message.
	 * @param aim Aim of the message.
	 */
	public SendMessageOneShotBehaviour(final String destination,
	        final String message, final int aim) {
		super();
		this.destination = new AID(destination, AID.ISLOCALNAME);
		this.message = message;
		this.aim = aim;
	}

	/**
	 * @see jade.core.behaviours.Behaviour#action()
	 */
	@Override
	public void action() {
		ACLMessage mensaje = new ACLMessage(aim);
		mensaje.addReceiver(destination);
		mensaje.setContent(message);
		myAgent.send(mensaje);
	}

}
